#include "Code.h"
#include "Beep.h"
#include "rtc.h"

int8_t encoder_count = 0;

void EncoderCount(void)
{
  uint8_t MSB = HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_5);
  uint8_t LSB = HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_6);
  uint8_t encoded = (MSB << 1) | LSB; 
	if(encoded == 2 || encoded == 1)
	{
		encoder_count++;
	}
	else if(encoded == 0 || encoded == 3)
	{
		encoder_count--;
	}

}

int16_t Encoder_GetValue(void)
{
	  int16_t value = encoder_count;
    encoder_count = 0;
    return value;
}


	



void Ok(void)
{
  /* USER CODE BEGIN EXTI4_IRQn 0 */
	printf("You Click Me\r\n");
	//Beep();
  /* USER CODE END EXTI4_IRQn 0 */
  
}
